package com.gome.ocean.common.constants;

/**
 * @author zhangguoqing 2016年10月13日 下午7:29:18
 * @since 5.0.0
 */
public class WebSqlContants {

    public static final String GROUP_LIST     = "group_list";  // 权限组
    public static final String GROUP_MEMBER   = "group_member";// 权限成员
    public static final String GROUP_PRIV     = "group_priv";  // 组权限
    public static final String GROUP_DB       = "group_db";    // 数据源信息
    public static final String GROUP_APPLY    = "priv_apply";  // 权限提交
    public static final String SQL_UPLOAD     = "upload";      // SQL提交
    public static final String SQL_CANCEL     = "cancel";      // SQL作废
    public static final String SQL_STATUS     = "astatus";     // SQL状态
    public static final String STATUS_0       = "0";           // 待提交
    public static final String STATUS_2       = "2";           // 待批准
    public static final String STATUS_4       = "4";           // 批准未通过
    public static final String STATUS_8       = "8";           // 已批准
    public static final String STATUS_16      = "16";          // DBA执行中
    public static final String STATUS_32      = "32";          // 执行失败
    public static final String STATUS_64      = "64";          // 执行成功
    public static final String STATUS_128     = "128";         // 作废
    public static final String CONMMON_PORT   = "31521";       // 获取表名称统一端口
    public static final String COMMON_DBNAME  = "GAMP";        // 统一DB名称
    public static final String GROUP_TYPE_DEV = "DEV";         // 组类型 代表 开发
    public static final String GROUP_TYPE_APP = "APP";         // 组类型 代表 应用程序

    public static final String GLOBAL_DECRYPT_P = "11e5L4NRV/ml7ThGty111"; // 全局密码

    public static final Integer CHECKOUT_RULE = 1;// 数据库检验规则

    public static final String GLOBLE_USER = "prd_pr_websql";   // websql获取库公共用户名称
    public static final String GLOBLE_PWD  = "4Q8MFVlGPmH9PvRV";// 独立密钥

    public static final String EXPORT_TYPE_ALL    = "all";          // 数据与结构
    public static final String EXPORT_TYPE_DATA   = "data";         // 数据
    public static final String EXPORT_TYPE_STRUCT = "create_script";// 结构

    public static final String EXPORT_YES = "Y";// YES
    public static final String EXPORT_NO  = "N";// NO

    public static final String EXPORT_SEVER_ADDS = "/app/download_file/"; // 服务器地址
    public static final String EXPORT_LOCAL_ADDS = "E:\\";                // 本地地址

    public static final String WEBSQL_PROCEDURE = "PROCEDURE"; // 存储过程
    public static final String WEBSQL_FUNCTION  = "FUNCTION";  // 函数
    public static final String WEBSQL_TRIGGER   = "TRIGGER";   // 触发器
    public static final String WEBSQL_EVENT     = "EVENT";     // 事件

    // 公告接口
    private static final String HTTP_NOTICE_QUERY_RESULT_PATH = "http://%s/mcenter/websql/api/notice?limit=%d,%d";
    // 获取数据库接口
    private static final String HTTP_DATABASE_PATH            = "http://%s/mcenter/websql/api/database?env_type=\'%s\'";
    // 获取应用名称接口
    private static final String HTTP_APPNAME_PATH             = "http://%s/mcenter/websql/api/application";
    // 获取权限组接口
    private static final String HTTP_AUTHORITY_GROUP_PATH     = "http://%s/mcenter/websql/api/privilege?pargs=%s";
    // 获取SQL提交接口
    private static final String HTTP_SQLUPLOAD_COMMIT_PATH    = "http://%s/mcenter/websql/api/sqlupload?pargs=%s";
    // 获取DSM数据源接口
    private static final String HTTP_DSM_DATASOURCE_PATH      = "http://%s/datasource/connInfo?appName=%s&env=%s&token=7QzTNGpbTgeYvQHraTxo8aGDZT2M3VtS";

    /**
     * 公告接口
     */
    public static String getFormatParamsNoticePathStr(String ip, Long spage, Long epage) {
        return String.format(HTTP_NOTICE_QUERY_RESULT_PATH, ip, spage, epage);
    }

    /**
     * 获取数据库接口
     */
    public static String getFormatParamsDataBasePathStr(String ip, String environmentType) {
        return String.format(HTTP_DATABASE_PATH, ip, environmentType);
    }

    /**
     * 获取应用名称接口
     */
    public static String getFormatAPPNamePathStr(String ip) {
        return String.format(HTTP_APPNAME_PATH, ip);
    }

    /**
     * 获取权限组接口
     */
    public static String getFormatAuthorityGroupPathStr(String ip, String paramJson) {
        return String.format(HTTP_AUTHORITY_GROUP_PATH, ip, paramJson);
    }

    /**
     * 获取SQL提交接口
     */
    public static String getFormatSQLUploadPathStr(String ip, String paramJson) {
        return String.format(HTTP_SQLUPLOAD_COMMIT_PATH, ip, paramJson);
    }

    /**
     * 获取DSM数据源接口
     */
    public static String getFormatDSMDatasourcePathStr(String ip, String appName, String envStr) {
        return String.format(HTTP_DSM_DATASOURCE_PATH, ip, appName, envStr);
    }
}
